function e(e, n) {
    if (!(e instanceof n)) throw new TypeError("Cannot call a class as a function");
}

Object.defineProperty(exports, "__esModule", {
    value: !0
});

var n = function() {
    function e(e, n) {
        for (var a = 0; a < n.length; a++) {
            var o = n[a];
            o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), 
            Object.defineProperty(e, o.key, o);
        }
    }
    return function(n, a, o) {
        return a && e(n.prototype, a), o && e(n, o), n;
    };
}(), a = function() {
    function a() {
        e(this, a), wxapp.webVersion = "", wxapp.res = {}, wxapp.res.loading = [ "res/games/newfish/img/lobby_bg.jpg", "res/games/newfish/img/lobby_bg.plist", "res/games/newfish/img/scale_bg1.plist", "res/games/newfish/img/scale_bg1.png", "res/games/newfish/img/lobby_bg.plist", "res/games/newfish/img/app_loading_bg.jpg", "res/games/newfish/img/lobby_common.plist", "res/games/newfish/img/lobby_common.png", "res/games/newfish/csb/lobby_common/screen_loading.json" ], 
        this.count = 0, this.counter = 0, this.showLoading1(), wxapp.tools.fileSystem.test(), 
        this.downloadVersion();
    }
    return n(a, [ {
        key: "showLoading1",
        value: function() {
            var e = canvas.width, n = canvas.height, a = canvas.getContext("2d"), o = wx.createImage();
            o.onload = function() {
                var i = o.width * n / e;
                a.drawImage(o, (e - i) / 2, 0, i, n);
            }, o.src = "images/fish_loading_bg.jpg";
        }
    }, {
        key: "downloadVersion",
        value: function() {
            var e = wxapp.objCenter.CreateObject2(this.callbackDownloadVersion, this);
            e.buildDownloadFile("version.json"), new wxapp.Downloader().downloadImageByUrl(e.url, e.name, e.success, e.fail, e.path);
        }
    }, {
        key: "callbackDownloadVersion",
        value: function(e) {
            if (e.isSuccess()) {
                var n = e.getResult().path, a = wx.getFileSystemManager(), o = wxapp.objCenter.CreateObject2(this.callbackCheckVersion, this);
                o.filePath = n, o.encoding = "utf8", a.readFile(o);
            }
        }
    }, {
        key: "callbackCheckVersion",
        value: function(e) {
            if (e.isSuccess()) {
                var n = JSON.parse(e.getResult().data), a = (n.path, n.version);
                wxapp.webVersion = a;
                var o = wxapp.objCenter.CreateObject2(this.callbackGetStorageVerion, this);
                o.key = wxapp.Const.StorageKey.Version, wx.getStorage(o);
            }
        }
    }, {
        key: "callbackGetStorageVerion",
        value: function(e) {
            var n = !1;
            if (e.isSuccess()) {
                var a = e.getResult().data;
                wxapp.webVersion == a && (n = !0);
            } else ;
            n ? this.run() : (wxapp.needUpdate = !0, this.downloadLoading1Res());
        }
    }, {
        key: "run",
        value: function() {
            cc.game.run();
        }
    }, {
        key: "downloadLoading1Res",
        value: function() {
            var e = new wxapp.DownloadFiles();
            e.addFile("res/HelloWorld.png"), wxapp.res.loading.forEach(function(n) {
                e.addFile(n);
            }), this.count = e.files.length, this.counter = 0, this.dl_fail = !1;
            var n = this, a = function(e) {
                console.log("success " + JSON.stringify(e)), n.counter++, n.counter >= n.count && n.endLoading();
            }, o = function(e) {
                console.log("fail " + JSON.stringify(e)), n.dl_fail = !0, n.counter++, n.counter >= n.count && n.endLoading();
            }, i = new wxapp.Downloader();
            e.getFiles().forEach(function(e) {
                var n = window.REMOTE_SERVER_ROOT + e.file, s = e.name, t = e.path;
                i.downloadImageByUrl(n, s, a, o, t);
            });
        }
    }, {
        key: "endLoading",
        value: function() {
            this.dl_fail || this.run();
        }
    } ]), a;
}();

exports.default = a, new a();